package main

import (
	"fmt"
)

func main() {
	var s string
	s = "san"
	fmt.Println(&s) // 0x1400012c010
	fmt.Println(s)

	// var n *string
	// *n = "string"
	// fmt.Println(n)

	var n *string
	n = new(string)
	*n = "string"
	fmt.Println(*n) // string

	p := person{name: "张三", age: 18}
	fmt.Println(p)
	pp := NewPerson()
	fmt.Println("name为", pp.name, ",age为", pp.age)
	pp1 := NewPersons("飞雪无情", 20)
	fmt.Println(pp1)
}

type person struct {
	name string
	age  int
}

func NewPerson() *person {
	p := new(person)
	p.name = "飞雪无情"
	p.age = 20
	return p
}

func NewPersons(name string, age int) *person {
	p := new(person)
	p.name = name
	p.age = age
	return p
}
